const Managers = require('../models/managers')

async function createManager(data) {
  return await Managers.create(data)
}
async function getManager(userName, password) {
  return await Managers.findOne({ where: { userName, password } })
}
async function managerLogin(userName, password) {
  return await getManager(userName, password)
}
async function getAllManagers() {
  return await Managers.findAll()
}
async function updateManagerPassword(id, password) {
  return await Managers.update({ password }, { where: { id } })
}
async function updateManagerInfo(id, data) {
  return await Managers.update(data, { where: { id } })
}
async function deleteManager(id) {
  return await Managers.destroy({ where: { id } })
}

module.exports = {
  createManager,
  getManager,
  managerLogin,
  getAllManagers,
  updateManagerPassword,
  updateManagerInfo,
  deleteManager,
}
